import React, { Component } from 'react';
import { DatePicker } from 'antd';

class FormDatePicker extends Component {
  render() {
    const { getData, onChange, value } = this.props;
    const dateFormat = getData('dateFormat') || [];
    const timeFormat = getData('timeFormat') || [];
    const showTime = timeFormat.length > 0;
    const format = `${dateFormat.join('-')} ${timeFormat.join(':')}`;
    return (
      <DatePicker
        onChange={onChange}
        format={format}
        showTime={showTime}
        value={value}
        style={{ width: '100%', height: '100%' }}
      />
    );
  }
}

export default FormDatePicker;
